﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.ComponentModel;

namespace MillerApp.CommonLib.Utility
{
    public class CommonHelper
    {
        public CommonHelper()
        {

        }
        /// <summary>
        /// 获取配置的AppSetting值
        /// </summary>
        /// <param name="key"></param>
        /// <returns>如果为没有配置则返回NULL，有则返回配置的值</returns>
        public string GetAppSettingConfig(string key)
        {
            if (ConfigurationManager.AppSettings.AllKeys.Contains(key)==false)
            {
                return null;
            }
            return ConfigurationManager.AppSettings[key];
        }

        public string GetFormatString4Number(decimal val)
        {
            return String.Format("{0:N}", val);
        }

        public static string GetDayOfWeekChinese(DayOfWeek day)
        {
            string result = string.Empty;
            switch (day)
            {
                case DayOfWeek.Monday:
                    result = "星期一";
                    break;
                case DayOfWeek.Tuesday:
                    result = "星期二";
                    break;
                case DayOfWeek.Wednesday:
                    result = "星期三";
                    break;
                case DayOfWeek.Thursday:
                    result = "星期四";
                    break;
                case DayOfWeek.Friday:
                    result = "星期五";
                    break;
                case DayOfWeek.Saturday:
                    result = "星期六";
                    break;
                case DayOfWeek.Sunday:
                    result = "星期天";
                    break;
                default:
                    break;
            }
            return result;
        }

        

    }
}
